#pragma once

#include "pch.h"
#include "MeshData.h"
#include "Animation.h"

namespace Model
{
    struct Serializer
    {

        int write_str(const std::string &s1, std::ofstream &ofs)
        {
            int len = s1.size();
            ofs.write((const char *)&len, sizeof(len));
            ofs.write(s1.c_str(), s1.size());

            return len;
        };

        int read_str(std::string &s1, std::ifstream &ifs)
        {

            int len2;
            ifs.read((char *)&len2, sizeof(len2));
            s1.resize(len2);
            ifs.read(&s1[0], len2);

            return len2;
        }

        
        void Encode(const MeshData &source, const std::string &path);
        void Decode(MeshData &source, const std::string &path);

        void Encode(const MeshData &source, std::ofstream &ofs);
        void Decode(MeshData &source, std::ifstream &ifs);

        
    };
};